﻿<%@ WebHandler Language="C#" Class="detail" %>
using Models;
using System;
using System.Web;
using Newtonsoft.Json;
using System.Linq;
using System.Collections.Generic;

public class detail : IHttpHandler {

    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";

        string authtoken = context.Request.Headers["token"];//Header中的token
        if (string.IsNullOrEmpty(authtoken))
        {
            HttpContext.Current.Response.Write("parameter error");
            return;
        }
        var code = 1;
        var msg = "用户信息";
        var time = DateTime.Now;

        using (Entities bll = new Entities())
        {


            var x = bll.User.FirstOrDefault(p => p.UOpenID == authtoken);
            var data = new
            {
                id=x.UID,
                avatar = x.UHeadImg,
                username = x.UNickName,
                nickname=x.UNickName,
                mobile=x.UTel,
                token = x.UGuid,
                group = new {name=_rky.getUstat(x.Ustate.ToString()),image="https://js.50cms.com/up/jg.png" },
                xinji=x.Ustate,
                is_store=x.Ustate
            };

            context.Response.Write(JsonConvert.SerializeObject(new {code,msg,time,data}));

        }

        HttpContext.Current.Response.End();
        //context.Response.Write("Hello World");


    }





    public bool IsReusable {
        get {
            return false;
        }
    }

}